フルパス名に対応する既存のオブジェクトを戻します。すなわち、Softimage オブジェクトの文字列表現をObject
Model の表現に変換します。このメソッドはGetValueコマンドに似ています。ただし、Parameterオブジェクトの場合は、Dictionary.GetObject
がパラメータオブジェクトを戻し、GetValue がパラメータ値を戻します(以下の例を参照)。
(オブジェクトモデル表現から文字列に)変換方向を変える場合は、SIObject.FullNameを使用します。
oReturn = Dictionary.GetObject( Pathname, [ThrowError] ); |
検索されたオブジェクト
| パラメータ | タイプ | 詳細 |
|---|---|---|
| Pathname | String | 検索するオブジェクトのフルパス名 |
| ThrowError | Boolean | デフォルトでは、オブジェクトが存在しない場合、Softimage
はスクリプトエラーを戻します。オブジェクトが存在するかどうかがわからない場合、またはこの引数値としてfalse
を渡さない場合、Softimage はエラーではなくヌルを戻します。これは v5.0で初めて導入されたパラメータです。
デフォルト値: true |
'
' Demonstrates usage of the Dictionary.GetObject method
'
' Clear the current scene to avoid name clashes and create
' a new cone named "foo"
deleteall false
CreatePrim "Cone", "MeshSurface", "foo"
' Find the subdivu parameter from the cone and set it to 10
Set oSubdivuParam = Dictionary.GetObject("foo.polymsh.geom.subdivu")
Application.LogMessage "Found a " & oSubdivuParam.type ' Outputs "Found a Parameter"
SetValue oSubdivuParam, 10
' Find the cone by its name and delete it
Set oCone = Dictionary.GetObject("foo")
Application.LogMessage "Found a " & oCone.type ' Outputs "Found a polymsh"
DeleteObj (oCone)
|
/*
Demonstrates usage of the Dictionary.GetObject method
*/
NewScene(null,false);
var oModel = ActiveSceneRoot.AddModel(new ActiveXObject("XSI.Collection"),"MyMdl") ;
var oNull = oModel.AddNull( "MyN" );
var oSphere = oNull.AddGeometry("Sphere","MeshSurface","MyS");
// Expect "MyMdl.MyS"
Application.LogMessage( oSphere.FullName ) ;
// Retrieve the sphere again, this time via its string name
oSphere = Dictionary.GetObject( "MyMdl.MyS" )
// The sphere is actually nested underneath the Null so you can also specify it like this
oSphere = Dictionary.GetObject( "MyMdl.MyN.MyS" )
// Now look at one of the parameters under the sphere
// Expect "MyMdl.MyS.kine.local.posx"
Application.LogMessage( oSphere.Kinematics.Local.Parameters("posx").FullName );
// First move the sphere to a recognizable position
SetValue( "MyMdl.MyS.kine.local.posx", 7.5 )
// Calling GetValue will return the VALUE of posx parameter
var paramValue = GetValue( "MyMdl.MyS.kine.local.posx" ) ;
// Expect "number,7.5"
Application.LogMessage( typeof( paramValue ) + "," + paramValue);
// But calling Dictionary.GetObject will return the
// actual Parameter object
var oParameter = Dictionary.GetObject( "MyMdl.MyS.kine.local.posx" )
// Expect "object,Parameter,7.5"
Application.LogMessage( typeof( oParameter ) + "," + Application.ClassName(oParameter) + "," + oParameter.Value ) ;
|
'
' This example shows how to find an object by its name, and to create it if it doesn't already exists.
' In this case we reuse the Annotation that has a specific name if it is already present at the scene root.
'
NewScene , false
dim strAnnotationName
strAnnotationName = "MyAnnotation"
set oObj = Dictionary.GetObject( strAnnotationName, false )
if TypeName( oObj ) = "Nothing" then
set oObj = ActiveSceneRoot.AddProperty( "Annotation", false, strAnnotationName )
end if
InspectObj( oObj )
|
/*
This example shows how to find an object by its name, and to create it if it doesn't already exists.
In this case we reuse the Annotation that has a specific name if it is already present at the scene root.
*/
var strAnnotationName = "MyAnnotation" ;
var oObj = Dictionary.GetObject( strAnnotationName, false ) ;
if ( !oObj ) {
var oObj = ActiveSceneRoot.AddProperty( "Annotation", false, strAnnotationName ) ;
}
InspectObj( oObj )
|